package com.geli.smarttools.date;

/**
 * <p>
 * <p>
 * 下面是空调遥控器编码
 * 格力空调遥控器（YB0F2）红外码组成如下，按解码顺序排列 <br>
 * 起始码（S）+35位数据码+连接码（C）+32位数据码 <br>
 * 各种编码的电平宽度： <br>
 * 数据码由“0”“1”组成： <br>
 * 0的电平宽度为：600us低电平+600us高电平， <br>
 * 1的电平宽度为：600us低电平+1600us高电平 <br>
 * 起始码S电平宽度为：9000us低电平+4500us高电平   <br>
 * 连接码C电平宽度为：600us低电平+20000us高电平  <br>
 * <p>
 * 校验码的形成机制如下：   <br>
 * 校验码 = [(模式 – 1) + (温度 – 16) + 5 +左右扫风+换气+节能]取二进制后四位，再逆序；  <br>
 * <p>
 * 例如：如果需要设置一下的状态，模式4，30℃，左右扫风，换气关闭，节能关闭，那么校验码为：  <br>
 * (4 – 1)+(30-16)+5+1+0+0= 23,取低四位为0111，逆序后为1110  <br>
 * <p>
 * 为了方便编码，在编码时可以正序，解码端再逆序，解码的时候先解码低字节，再解码高字节的位。  <br>
 * 另外定时数据对最后的校验码的影响没有测试，因为很少会用到这个功能。  <br>
 */

public class CodeCommand {

    /**
     * 起始码S电平宽度为：9000us低电平+4500us高电平
     */
    private static final int startdown = 9000;
    private static final int startup = 4500;

    /**
     * 连接码C电平宽度为：600us低电平+20000us高电平
     */
    private static final int connectdown = 600;
    private static final int connectup = 20000;


    /**
     * 0的电平宽度为：600us低电平+600us高电平，
     */
    public static final int zerodown = 600;
    public static final int zeroup = 600;

    /**
     * 1的电平宽度为：600us低电平+1600us高电平
     */
    public static final int onedown = 600;
    public static final int oneup = 1600;

    //校验码--1
    public static int check_d = 600;
    public static int check_u = 1600;

    public static final int[] base = {
            startdown, startup,//起始码
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//1-3
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//4-6
            onedown, oneup, zerodown, zeroup, zerodown, zeroup,//7-9
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//10-12
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//13-15
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//16-18
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//19-21
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//22-24
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//25-27
            zerodown, zeroup, onedown, oneup, zerodown, zeroup,//28-30
            onedown, oneup, zerodown, zeroup, zerodown, zeroup,//31-33
            onedown, oneup, zerodown, zeroup,//34-35  前35位数据码结束
            connectdown, connectup,//连接码   后32位开始
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//36-38
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//39-41
            zerodown, zeroup, zerodown, zeroup, onedown, oneup,//42-44
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//45-47
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//48-50
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//51-53
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//54-56
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//57-59
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//60-62
            zerodown, zeroup, //63
            zerodown, zeroup, zerodown, zeroup, zerodown, zeroup, zerodown, zeroup,//64-67(四位检验码)后32位结束

    };



}
